/**
 * OrderQueryComp
 * Created by xzp on 2017-4-28 10:25:29
 */
 //***********************查询订单***********************
/*Comps.OrderQueryComp = function(option){
    this.compId = option.compId;
    this.needAsyncInit = option.needAsyncInit;
    this.txt_orderQueryUrl = option.txt_orderQueryUrl;
}

Comps.OrderQueryComp.prototype.init = function(){
    var that = this;
    
      Utils.ajaxLoadComplate(that);
      $("#"+this.compId+"_orderQueryUrl").attr("href",ContextPath+this.txt_orderQueryUrl);
}*/
var canSendmsgFlag = true;//是否发送验证码的标识，防止重复请求
Comps.OrderQueryComp = function(option) {
    this.compId = option.compId;
    this.needAsyncInit = option.needAsyncInit;
    this.codeUrl = option.codeUrl;
    //this.codeUrl = "/sendPhoneCode";
    this.orderSearchUrl = option.txt_orderQueryUrl;
    this.orderQueryTitle = option.orderQueryTitle;
}
Comps.OrderQueryComp.prototype.init = function(){
    var that = this;

    if (this.needAsyncInit) {
        $("#" + that.compId + "_orderQueryTitle").html(that.orderQueryTitle);
    }

    Utils.ajaxLoadComplate(that);

    that.bindSomeEvent();
}
Comps.OrderQueryComp.prototype.bindSomeEvent=function(){
    var that=this;
    $("#"+that.compId+"_codeQueryUrl").click(function(){
        var phone = $("#"+that.compId+"_phone").val();
        var reg = /^1\d{10}$/;
		if(phone==null || phone ==""){
			alert("请输入手机号");
			return;
		}else if(!reg.test(phone)){
			alert("请输入正确的手机号");
			return;
		}
        //$("#" + that.compId + "_a").attr("href",that.codeUrl+"?phone="+phone);
        //window.open(ContextPath+that.codeUrl+"?phone="+phone);
	if(canSendmsgFlag){	
		var url = ContextPath+that.codeUrl;	
		$.getJSON(url,{phone:phone, ranNum:Math.random()},function(data){
			if(data.flag=="sendRegMsgFail"){
				alert("短信验证码发送失败!");
				return;
			}else{
				var sessionId = data.sessionId;
				$("#"+that.compId).append("<input type='hidden' id='sessionId'/>");
				$("#sessionId").val(sessionId);
				time(that);
			}
		})
    }	
});
    $("#"+this.compId+"_orderQueryUrl").click(function(){
    	 var phone = $("#"+that.compId+"_phone").val();
         var code = $("#"+that.compId+"_code").val();
         var sessionId = $("#sessionId").val();
        if(sessionId == null ||sessionId =="undefine"){
        	sessionId = "";
        }
        var reg = /^1\d{10}$/;
        if(phone==null || phone ==""){
			alert("请输入手机号");
			return;
		}else if(!reg.test(phone)){
			alert("请输入正确的手机号");
			return;
		}else if(code==null || code ==""){
			alert("验证码不能为空");
			return;
		}
        window.open(ContextPath+that.orderSearchUrl+"?phone="+phone+"&code="+code+"&sessionId="+sessionId);
    })

}
var wait=60;
function time(o) {
  if (wait == 0) {
	  canSendmsgFlag = true;
	  //获取验证码按钮解除禁用
	  $("#"+o.compId+"_codeQueryUrl").attr("disabled", false);
	  $("#"+o.compId+"_codeQueryUrl").text("重新获取验证码");
      wait = 60;
  } else {
	  canSendmsgFlag = false;
     // 禁用获取验证码按钮
	  $("#"+o.compId+"_codeQueryUrl").attr("disabled", true);
      $("#"+o.compId+"_codeQueryUrl").text(wait+"秒后重发");
      wait--;
      setTimeout(function() {
          time(o);
      },
      1000)
  }
}

/**
 * HotSellComp
 * Created by xzp on 2017-5-2 15:44:16
 */
 //***********************热卖套餐***********************
Comps.HotSellComp = function(option){
   this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.name = option.name;
	this.imgSrc = option.imgSrc;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.param_inProductUuids = option.param_inProductUuids;
}

Comps.HotSellComp.prototype.init = function(){
	var that =this;
	if (this.needAsyncInit) {
		$("#"+that.compId+"_img").attr("src",that.imgSrc);
		$("#"+that.compId+"_img").attr("width",that.defineWidth);
		$("#"+that.compId+"_img").attr("height",that.defineHeight);
		$("#"+that.compId+"_name").val(that.name);
		$("#"+that.compId+"_defineUrl").attr("href", ContextPath +"/item/"+ that.param_inProductUuids+".htm");
	}

	this.bindEvent();
	Utils.ajaxLoadComplate(that);
}

Comps.HotSellComp.prototype.bindEvent = function(){
	var that =this;
	//热卖套餐
    $(".m-recommended").hover(function(){
    	$(this).addClass('active');
    },function(){
    	$(this).removeClass('active');
    });
    for(var i=0;i<$(".m-recommended").length;i++){
        if(i==1){
            $(".m-recommended").eq(1).addClass("m-li1");
        }else if(i==2){
            $(".m-recommended").eq(2).addClass("m-li2");
        }else{
            $(".m-recommended").eq(3).addClass("m-li3");
        }
    }
};

/**
 * BurstProductComp
 * Created by xzp on 2017-5-3 16:59:36
 */
 //***********************爆款单品***********************
Comps.BurstProductComp = function(option){
	this.compId = option.compId;
	this.productUuid = option.param_inProductUuids;
	this.needAsyncInit = option.needAsyncInit;
	this.productUrl=option.productUrl;
	this.layoutName=option.layoutName;
	this.defineWidth=option.defineWidth;
	this.defineHeight=option.defineHeight;
	this.imgsrc=option.imgsrc;
	this.defineWidthSales=option.defineWidthSales;
    this.defineHeightSales=option.defineHeightSales;
    this.imgSrcSales=option.imgSrcSales;

}

Comps.BurstProductComp.prototype.init=function(){
	var that=this;
	if(that.layoutName){
		$("#"+that.compId+"_across").show();
		$("#"+that.compId+"_erect").remove();
	}else{
		$("#"+that.compId+"_across").remove();
		$("#"+that.compId+"_erect").show();
	}

	if (this.needAsyncInit) {
	    $.ajax({
	        type: "GET",
	        url: ContextPath + "/burstProductComp/ajaxLoadData",
	        data: {
	            productUuid: that.productUuid
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {

	        	$("#"+that.compId+"_price").html("￥"+data.price.toFixed(2));
	        	$("#"+that.compId+"_href").attr("uuid",data.productUuid);
	        	$("#"+that.compId+"_href").attr("href",ContextPath + "/item/" + data.productNo+".htm");
	        	$("#"+that.compId+"_name").html(data.name);
	        	$("#"+that.compId+"_img").attr("src",that.imgsrc);
	        	$("#"+that.compId+"_img").attr("width",that.defineWidth);
	        	$("#"+that.compId+"_img").attr("height",that.defineHeight);

	        	$("#"+that.compId+"_sales").attr("src",that.imgSrcSales);
                $("#"+that.compId+"_sales").attr("width",that.defineWidthSales);
                $("#"+that.compId+"_sales").attr("height",that.defineHeightSales);

	        	Utils.ajaxLoadComplate(that);
	        }
	    })
	} else {
	    Utils.ajaxLoadComplate(that);
	}
}

/**
 * EmphasisCaseComp
 * Created by xzp on 2017年5月11日14:45:30
 */
 //***********************重点案例***********************

 Comps.EmphasisCaseComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.caseUuid = option.param_incaseUuids;
	this.defineWidth = option.defineWidth;
	this.defineHeight=option.defineHeight;
	this.defineUrl=option.defineUrl;
	this.layout=option.layout;
	this.imagesrc=option.imagesrc;
}

Comps.EmphasisCaseComp.prototype.init=function(){
	var that=this;

	//如果是右侧
	if (!this.layout) {
		$("#"+ that.compId +"_casea").removeClass('c-casea').addClass('case-right');
		$("#"+ that.compId +"_character").removeClass('item-h').addClass('item-w');
	};

	if (this.needAsyncInit) {
	    $.ajax({
	        type: "GET",
	        url: ContextPath + "/emphasisCaseComp/ajaxLoadData",
	        data: {
	            caseUuid: that.caseUuid
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {
	        	
	        	$("#"+that.compId+"_character").text(data.caseName);
	        	$("#"+that.compId+"_img").attr("src",that.imagesrc);

                if(data.anotherName != ""){
                    $("#"+that.compId+"_character").attr("href",that.defineUrl+"/"+data.anotherName+".htm");
                }else{
                    $("#"+that.compId+"_character").attr("href",that.defineUrl+"/"+that.caseUuid+".htm");
                }

	        	$("#"+that.compId+"_img").attr("width",that.defineWidth);
	        	$("#"+that.compId+"_img").attr("height",that.defineHeight);
				
	        	Utils.ajaxLoadComplate(that);
	        }
	    })
	} else {
	    Utils.ajaxLoadComplate(that);
	}
}


/**
 * VidePrefectureComp
 * Created by xzp on 2017年5月12日09:59:07
 */
 //***********************视频专区***********************

 Comps.videPrefectureComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.videoUrl = option.videoUrl;
	this.videoName = option.videoName;
	this.imgSrc = option.imgSrc;
    this.defineWidth = option.defineWidth;
    this.defineHeight = option.defineHeight;
}

Comps.videPrefectureComp.prototype.init=function(){
	var that=this;

	if (this.needAsyncInit) {

		$("#"+that.compId+"_text").text(that.videoName);
		$("#"+that.compId+"_vide").attr("src",that.videoUrl);

		Utils.ajaxLoadComplate(that);
	} else {
		Utils.ajaxLoadComplate(that);
	}

    $(".v-gallery-play").on("click",function(){
    	var videoDom = document.querySelector("video").play();
    	$(".v-gallery-play").css("display","none");
    })

    $(".v-list-bottom li .video-img").on("click",function() {
  		var imgSrc = $(this).attr("num");
  		$("#"+that.compId+"_text").html($(this).attr("videoName"));
  		var videoDom = document.querySelector("video");
  		videoDom.src = imgSrc;
  		videoDom.play();
  		$(".v-gallery-play").css("display","none");
    });

    //$(".v-list-bottom").niceScroll();
    
}

/**
 * VidePrefectureComp
 * Created by xzp on 2017年5月12日10:40:48
 */
 //***********************视频列表***********************

 Comps.VideoListComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.adUuid = option.adUuid;
}

Comps.VideoListComp.prototype.init = function() {
  var that = this;
  if (this.adUuid == "" || this.adUuid == undefined || this.adUuid == null) {
    Utils.ajaxLoadComplate(that);
    return;
  }

  if (this.needAsyncInit) {
    $.ajax({
      type: "GET",
      url: ContextPath + "/slideAds/ajaxLoadData",
      data: {
        adUuid: this.adUuid
      },
      dataType: "json",
      success: function(data) {
        //1.获取返回的广告、图片url
        var listData = eval(data);
        var urlList;

        //3、获取广告图片所在ul，并克隆节点
        var bgUl = $("#videolist");
        var bgUlClone = "";
        var bgLiClone = bgUl.children(0);

        //4、生成锚点及广告图片节点
        var imgUrl = "";
        var downloadUrl = "";
        var videoUrl = "";
        var name = "";
        for (var i = 0; i < listData.length; i++) {
          adUrl = listData[i];
          urlList = adUrl.split(";");
          if (urlList.length == 4) {
            imgUrl = urlList[0];
            downloadUrl = urlList[1];
            name = urlList[2];
            videoUrl = urlList[3];
          } 
          //视频地址
          bgLiClone.find("a").first().children().attr("src",imgUrl);
          bgLiClone.find("a").last().attr("href",downloadUrl);
          bgLiClone.find("a").first().attr("num",videoUrl);
          bgLiClone.find("a").first().attr("videoName",name);
		  bgLiClone.find("p").text(name);

          bgUlClone += bgLiClone[0].outerHTML;
        }

        //5、替换原有节点
        bgUl.children(0).replaceWith(bgUlClone);
        Utils.ajaxLoadComplate(that);
      }
    });
  } else {
    Utils.ajaxLoadComplate(that);
  }
}


/**
 * StarProductComp
 * Created by xzp on 2017年5月16日09:33:01
 */
 //***********************明星商品***********************

 Comps.StarProductComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.imgsrc = option.imgsrc;
	this.productUrl = option.productUrl;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.param_inProductUuids = option.param_inProductUuids;
}

Comps.StarProductComp.prototype.init=function(){
	var that=this;

	if (this.needAsyncInit) {
		  $.ajax({
	        type: "GET",
	        url: ContextPath + "/burstProductComp/ajaxLoadData",
	        data: {
	            productUuid: that.param_inProductUuids
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {

	        	if(data.productNo != ""){
	        	    $("#"+that.compId+"_href").attr("href",ContextPath +"/citem/"+data.productNo+".htm");
	        	}else{
	        	    $("#"+that.compId+"_href").attr("href",ContextPath +"/citem/"+data.productUuid+".htm");
	        	}
	        	$("#"+that.compId+"_name").html(data.name);
	        	$("#"+that.compId+"_img").attr("src",that.imgsrc);
	        	$("#"+that.compId+"_img").attr("width",that.defineWidth);
	        	$("#"+that.compId+"_img").attr("height",that.defineHeight);
				
	        	Utils.ajaxLoadComplate(that);
	        }
	    })
	} else {
		Utils.ajaxLoadComplate(that);
	}
}


/**
 * HotInformationComp
 * Created by xzp on 2017年5月19日15:05:56
 */
 //***********************热门资讯***********************

 Comps.HotInformationComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.informationUrl = option.informationUrl;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.contentUuid = option.contentUuid;
	this.whereSize = option.whereSize;
}

Comps.HotInformationComp.prototype.init=function(){
	var that=this;


	if (this.needAsyncInit) {
		  $.ajax({
	        type: "GET",
	        url: ContextPath + "/hotInformationComp/ajaxLoadData",
	        data: {
	            contentUuid: that.contentUuid
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {

	        	if (that.whereSize) {
	        		$("#"+that.compId+"_size").attr("class",'item_l');
	        	}else{
	        		$("#"+that.compId+"_size").attr("class",'m_item');
	        	}
	        	
	        	$("#"+that.compId+"_img").attr("src",data.contentImgUrl);
	        	$("#"+that.compId+"_text").text(data.contentTitle);
	        	$("#"+that.compId+"_href").attr("href",that.informationUrl);
	        	$("#"+that.compId+"_text").attr("href",that.informationUrl);
   	       	$("#"+that.compId+"_img").attr("width",that.defineWidth);
	        	$("#"+that.compId+"_img").attr("height",that.defineHeight);

	        	Utils.ajaxLoadComplate(that);
	        }
	    })
	} else {
		Utils.ajaxLoadComplate(that);
	}
}


/**
 * HotNewsComp
 * Created by xzp on 2017年5月22日10:38:14
 */
 //***********************热门新闻***********************

 Comps.HotNewsComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.informationUrl = option.informationUrl;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.contentUuid = option.contentUuid;
	this.whereSize = option.whereSize;
}

Comps.HotNewsComp.prototype.init=function(){
	var that=this;

	if (that.whereSize) {
     	$("#"+that.compId+"_left").show();
     	$("#"+that.compId+"_right").remove();
	}else{
		$("#"+that.compId+"_left").remove();
		$("#"+that.compId+"_right").show();
	}

	if (this.needAsyncInit) {
		  $.ajax({
	        type: "GET",
	        url: ContextPath + "/hotNewsComp/ajaxLoadData",
	        data: {
	            contentUuid: that.contentUuid
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {
	        	$("#"+that.compId+"_img").attr("src",data.contentImgUrl);
	        	$("#"+that.compId+"_name").text(data.contentTitle);
	        	$("#"+that.compId+"_text").text(data.contentValue);

	        	$("#"+that.compId+"_href").attr("href",that.informationUrl);
	        	$("#"+that.compId+"_name").attr("href",that.informationUrl);
	        	$("#"+that.compId+"_text").attr("href",that.informationUrl);
   	       	$("#"+that.compId+"_img").attr("width",that.defineWidth);
	        	$("#"+that.compId+"_img").attr("height",that.defineHeight);

	        	Utils.ajaxLoadComplate(that);
	        }
	    })
	} else {
		Utils.ajaxLoadComplate(that);
	}
}

/**
 * HeadlineComp
 * Created by xzp on 2017-4-28 10:25:29
 */
 //***********************资讯标题***********************
Comps.HeadlineComp = function(option){
	this.compId = option.compId;
    this.needAsyncInit = option.needAsyncInit;
    this.titleName = option.titleName;
    this.informationUrl = option.informationUrl;
    this.isDisplay = option.display;
}

Comps.HeadlineComp.prototype.init = function(){
    var that = this;
    
	if (that.needAsyncInit) {

		//是否隐藏链接
		if (!that.isDisplay) {
			$("#"+that.compId+"_href").hide();
		}else{
			$("#"+that.compId+"_href").attr("href",that.informationUrl);
		}

      $("#"+that.compId+"_name").text(that.titleName);

      Utils.ajaxLoadComplate(that);
	}else{
      Utils.ajaxLoadComplate(that);
	}
}



/**
 * HotContentComp
 * Created by xzp on 2017年5月22日10:38:14
 */
 //***********************资讯内容***********************

 Comps.HotContentComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.informationUrl = option.informationUrl;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.contentUuid = option.contentUuid;
}

Comps.HotContentComp.prototype.init=function(){
	var that=this;

	if (this.needAsyncInit) {
		  $.ajax({
	        type: "GET",
	        url: ContextPath + "/hotContentComp/ajaxLoadData",
	        data: {
	            contentUuid: that.contentUuid
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {
	        	$("#"+that.compId+"_img").attr("src",data.contentImgUrl);
	        	$("#"+that.compId+"_name").text(data.contentTitle);
	        	$("#"+that.compId+"_text").text(data.contentValue);

	        	$("#"+that.compId+"_href").attr("href",that.informationUrl);
	        	$("#"+that.compId+"_name").attr("href",that.informationUrl);
	        	$("#"+that.compId+"_text").attr("href",that.informationUrl);
   	       	$("#"+that.compId+"_img").attr("width",that.defineWidth);
	        	$("#"+that.compId+"_img").attr("height",that.defineHeight);

	        	Utils.ajaxLoadComplate(that);
	        }
	    })
	} else {
		Utils.ajaxLoadComplate(that);
	}
}


/**
 * RecommendComp
 * Created by xzp on 2017年5月22日18:30:14
 */
 //***********************资讯推荐***********************

 Comps.RecommendComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.categoryUuid2 = option.categoryUuid2;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.pageShow = option.pageShow;
	this.categpryName2 = option.categpryName2;
}

Comps.RecommendComp.prototype.init=function(){
	var that=this;

	if (this.needAsyncInit) {
		  $.ajax({
	        type: "GET",
	        url: ContextPath + "/recommendComp/ajaxLoadData",
	        data: {
	            categoryUuid: that.categoryUuid2,
	            pageShow: that.pageShow
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {

	        	if (data.rows.length == 0) {
	        		$("#"+that.compId).remove();
	        		return
	        	};
	        	var a = $("#"+that.compId+"_a").parents().clone();
	        	var b = $("#"+that.compId+"_b").parents().clone();

	        	$("#"+that.compId+"_show_a").empty();
	        	$("#"+that.compId+"_show_b").empty();

	        	$("#"+that.compId+"_title").text(that.categpryName2);

	        	$.each(data.rows, function(index, val) {		

	        		if(val.contentImgUrl == '' || val.contentImgUrl == 'null'){
					
						b.find('a').attr("href",val.url).text(val.contentTitle)

						$("#"+that.compId+"_show_b").append(b.html());
	        		}else{
        			  	
        			  	a.find('a').first().attr("href",val.url);
      			  		a.find('img').attr("src",val.contentImgUrl).attr("width",that.defineWidth).attr("height",that.defineHeight);
   			  		 	a.find('p').first().attr("href",val.url).text(val.contentTitle);

 			  		 	$("#"+that.compId+"_show_a").append(a.html());
	        		}

	        	});
	   
	        	Utils.ajaxLoadComplate(that);
	        }
	    })

		
		
	} else {
		Utils.ajaxLoadComplate(that);
	}
}


/**
 * CommercialButtComp
 * Created by xzp on 2017年5月25日15:50:37
 */
 //***********************商务对接***********************

 Comps.CommercialButtComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.defineWidth1 = option.defineWidth1;
	this.defineHeight1 = option.defineHeight1;
	this.title = option.title;
	this.skipUrl = option.skipUrl;
	this.imgsrc = option.imgsrc;
	this.imgsrc1 = option.imgsrc1;
	this.describe = option.describe;
}

Comps.CommercialButtComp.prototype.init=function(){
	var that=this;

	if (that.needAsyncInit) {
		
		$("#"+that.compId+"_href").attr("href",that.skipUrl);
		
		$("#"+that.compId+"_text").text(that.title);

        $("#"+that.compId+"_describe").html(decodeURI($.base64.decode(that.describe)));
		$("#"+that.compId+"_log").attr("imgSrc",that.imgsrc);
		$("#"+that.compId+"_log").attr("width",that.defineWidth);
		$("#"+that.compId+"_log").attr("height",that.defineHeight);

		$("#"+that.compId+"_img").attr("src",that.imgsrc1);
		$("#"+that.compId+"_img").attr("width",that.defineWidth1);
		$("#"+that.compId+"_img").attr("height",that.defineHeight1);
        that._bindEvent();
	} else {
		Utils.ajaxLoadComplate(that);
		//绑定事件
        that._bindEvent();
	}
}

Comps.CommercialButtComp.prototype._bindEvent = function () {
   $(".m_business").hover(function(){
   	    	$(this).find(".business_tit").addClass('active');
   	    },function(){
   	    	$(this).find(".business_tit").removeClass('active');
   	});
}


/**
 * CommercialButtComp
 * Created by xzp on 2017年5月25日15:50:37
 */
 //***********************服务支持***********************

 Comps.ServeSupportComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
	this.uuids = option.uuids;
	this.imgUrl = option.imgUrl;
	this.title = option.title;
}

Comps.ServeSupportComp.prototype.init=function(){
	var that=this;

	if (that.needAsyncInit) {
		  $.ajax({
	        type: "GET",
	        url: ContextPath + "/serveSupportComp/ajaxLoadData",
	        data: {
	            uuids: that.uuids
	        },
	        dataType: "json",
	        async: true,
	        success: function(data) {
	        	var li = $("#"+that.compId+"_ul").children().clone();

	        	$("#"+that.compId+"_ul").empty();
				$("#"+that.compId+"_img").attr("src",that.imgUrl);
				$("#"+that.compId+"_img").attr("width",that.defineWidth);
				$("#"+that.compId+"_img").attr("height",that.defineHeight);
				$("#"+that.compId+"_text").text(that.title);
	        	if (data.length == 0) {
	        		return ;
	        	};

	        	$.each(data, function(index, val) {
	        		var htm = li.clone();
	        		htm.find('a').attr("href", ContextPath + "/brandnews/" +val.contentId+".htm").text(val.contentTitle);
	        		$("#"+that.compId+"_ul").append(htm);
	        	});
	        	Utils.ajaxLoadComplate(that);
	        }
	    })

	} else {
		Utils.ajaxLoadComplate(that);
	}
}

/**
 * LuckdrawComp
 * Created by xzp on 2017年6月12日10:52:33
 */
 //***********************抽奖***********************
Comps.LuckdrawComp = function(option){
   this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.activityName = option.activityName;
	this.activityRemark = option.activityRemark;
	this.imgSrc = option.imgSrc;
	this.defineWidth = option.defineWidth;
	this.defineHeight = option.defineHeight;
}

Comps.LuckdrawComp.prototype.init = function(){
    var that = this;
    
    if (that.needAsyncInit) {
    	$("#"+that.compId+"_img").attr("src",that.imgSrc);
    	$("#"+that.compId+"_img").attr("width",that.defineWidth);
    	$("#"+that.compId+"_img").attr("height",that.defineHeight);
    	$("#"+that.compId+"_title").html(that.activityName);
    	$("#"+that.compId+"_remark").html(that.activityRemark);
    };

    Utils.ajaxLoadComplate(that);
    CompMessage.subscribe("openLuckdraw",function(a,b){
    	$.ajax({
    		url: ContextPath+"/luckdrawComp/openLuckdraw",
    		dataType:"html",
			type:"GET",
    		"success": function (data) {
    			$("#" + that.compId + "_show").html(data);
    			a();
    		}
    	})
    });

    //是否自动显示抽奖
   var luckdraw =  $("#luckdraw").val();
   if ("show" == luckdraw) {
   		openLucjdraw();
   };
}

//防止重复点击
  var luckFlag = true;
  function openLucjdraw(){
  	var loginUrl = ContextPath +"/cart/isLogin"	
	$.get(loginUrl,{ranNum:Math.random()} ,function(data){
		if("0"==data) {
            $("#modal-login-form").modal();
		}else{
			if (luckFlag) {
				luckFlag = false;
				CompMessage.publish("openLuckdraw", function () {
					luckFlag = true;
				});
			};
		}
	});
  }
  

/**
 * ContentListComp
 * Created by xzp on 2017-5-2 15:44:16
 */
 //***********************内容列表***********************
 
Comps.ContentListComp = function(option){
    this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.tagsUuids = option.tagsUuids;
	this.tagsNames = option.tagsNames;
}

Comps.ContentListComp.prototype.init = function(){
	var that = this;
	if (this.needAsyncInit) {
		var ul = $("#"+that.compId).find("ul");
		var li = ul.find("li");
		ul.empty();
		var tagsUuids = this.tagsUuids.split(",");
		var tagsNames = this.tagsNames.split(",");
		for (var i = 0; i < tagsNames.length; i++) {
			var uuid = tagsUuids[i];
			var name = tagsNames[i];
			li = li.clone();
			li.find("a").attr("href",ContextPath +"/frontshow/tagscategory/toCategory/"+ uuid +".html").text(name);
			ul.append(li);
		}
		$("#"+that.compId+"_more").attr("href",ContextPath +"/frontshow/tagscategory/getAllCategory");
	}
	this.bindEvent();
}

Comps.ContentListComp.prototype.bindEvent = function(){
	var that = this;
	//展开列表
	$("#"+that.compId+"_content").load(ContextPath +"/frontshow/content/getContentList?categoryUuid=JomooHomeHecoration");
};


/**
 * ContentRecommendComp
 * Created by xzp on 2017-5-2 15:44:16
 */
 //***********************热门推荐***********************
 
Comps.ContentRecommendComp = function(option){
    this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.contentUuids = option.contentUuids;
	this.contentNames = option.contentNames;
}

Comps.ContentRecommendComp.prototype.init = function() {
	var that = this;
	if(this.needAsyncInit) {
		$.ajax({
			type: "GET",
			url: ContextPath + "/contentRecommend/ajaxLoadData",
			data: {
				contentUuids: that.contentUuids
			},
			dataType: "json",
			async: true,
			success: function(data) {
				var div = $("#" + that.compId);
				var ul = div.find("ul");
				var li = ul.find("li");
				ul.empty();
				$.each(data, function(i,v) {
					li = li.clone();
					li.find(".m-pic").find("a").attr("href", ContextPath + "/frontshow/content/channel/" + v.uuid + ".html").find("img").attr("src",v.iconPath);
					li.find(".m_tit").find("a").attr("href", ContextPath + "/frontshow/content/channel/" + v.uuid + ".html").text(v.note);
					ul.append(li);
				});
			}
		})
	
	}
}